# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: NicoHood <archlinux {cat} nicohood {dog} de>

pkgname=python-snowboy
pkgver=1.3.0
pkgrel=5
pkgdesc="DNN based hotword and wake word detection toolkit"
url="https://github.com/Kitt-AI/snowboy"
license=('Apache')
arch=('loong64' 'x86_64')
depends=('python-pyaudio' 'cblas')
makedepends=('python-setuptools' 'swig')
source=("$pkgname-$pkgver.tar.gz::https://github.com/Kitt-AI/snowboy/archive/v$pkgver.tar.gz")
sha512sums=('3edd3038c11beb9ecc9a7f73f91c7097ec869841eade6715df061987313cdad60d7090d494f3d161bf64c921d5f75e8f64a2befc6bf7202b468f0122c7ecff1a')

prepare() {
  # TODO https://github.com/Kitt-AI/snowboy/issues/377
  # TODO https://github.com/Kitt-AI/snowboy/pull/376
  sed -i -e "s|-lf77blas -lcblas -llapack -latlas|-lcblas|g" \
         -e 's/ -shared/ -Wl,-O1,--as-needed\0/g' \
         snowboy-$pkgver/swig/Python3/Makefile
}

build() {
  cd snowboy-$pkgver
  python setup.py build
}

package() {
  cd snowboy-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
